#include "Window.h"
#include "IGraphicContext.h"
#include "IGraphicsDevice.h"

NS_B2D_BEGIN

BaseWindow::BaseWindow(void)
	: mContext(nullptr)
	, mExternalWindow(false)
	, mTitle("")
	, mPosition(0,0)
	, mFullscreen(false)
	, mDepthBits(0)
	, mColorBits(0)
{
}

void BaseWindow::render(IGraphicsDevice& g) const
{
	// For an external window we simply draw
	if( mExternalWindow == true )
		RenderTarget::render(g);
	// For a window created by the engine,
	// we must set its context and swap buffers
	else
	{
		mContext->makeCurrent();
		RenderTarget::render(g);
		mContext->swapBuffers(false);
	}
}

NS_B2D_END